package sing.cloud.alibaba.seata.controller;

import io.seata.core.context.RootContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import sing.cloud.alibaba.seata.service.IOrderService;
import sing.cloud.alibaba.seata.domain.CommonResult;
import sing.cloud.alibaba.seata.domain.Order;

/**
 * @author xing
 * @date 2022/9/3 17:49
 */
@RestController
@Slf4j
public class OrderController {
    @Autowired
    private IOrderService orderService;

    /**
     * 创建订单
     */
    @GetMapping("/order/create")
    public CommonResult create(Order order) {
//        String xid = RootContext.getXID();
//        log.info("xid in controller: {}", xid);
        orderService.create(order);
        return new CommonResult(200, "订单创建成功!");
    }
}
